//
//  WBVistorView.swift
//  微博
//
//  Created by hejinyin on 2017/9/1.
//  Copyright © 2017年 WangQiang. All rights reserved.
//

import UIKit
import SnapKit

class WBVistorView: UIView {
     lazy var registerButton = UIButton.init("注册", normalColor: UIColor.orange, highlightedColor: UIColor.black, fontSize: 16, backgroundImage: "common_button_white_disable")
    
     lazy var loginButton = UIButton.init("登录", normalColor: UIColor.black, highlightedColor: UIColor.orange, fontSize: 16, backgroundImage: "common_button_white_disable")
    
    
    fileprivate lazy var tipLabel = UILabel.init("关注一些人，回这里看看有什么惊喜关注一些人，回这里看看有什么惊喜", fontSize: 14, color: UIColor.darkText)
    
    var visitorInfo :[String:String]?{
        didSet{
            guard let imageName = visitorInfo?["imageName"],
                let message = visitorInfo?["message"]
                else {
                return
            }
            
            if imageName == "home" {//首页
                houseIconView.isHidden = false;
                iconView.startRotationAnimate(duration: 15.0)
                iconView.image = UIImage.init(named: "visitordiscover_feed_image_smallicon")
            }else{
                houseIconView.isHidden = true
                iconView.image = UIImage.init(named: imageName)
            }
            tipLabel.text = message
            
        }
    }
    fileprivate lazy var iconView = UIImageView.init(image: UIImage.init(named: "visitordiscover_feed_image_smallicon"))
    
    
    fileprivate lazy var maskIconView = UIImageView.init(image: UIImage.init(named: "visitordiscover_feed_mask_smallicon"))
    
    fileprivate lazy var houseIconView = UIImageView.init(image: UIImage.init(named: "visitordiscover_feed_image_house"))
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
extension WBVistorView{
    func setupUI ()  {
        addSubview(iconView)
        addSubview(maskIconView)
        addSubview(houseIconView)
        addSubview(tipLabel)
        addSubview(registerButton)
        addSubview(loginButton)
        
        backgroundColor = UIColor.init(hex: 0xEDEDED)
        
        tipLabel.textAlignment = .center
        tipLabel.numberOfLines = 0
        
        // 3. 自动布局
        let margin: CGFloat = 20.0
        iconView.snp.makeConstraints { (make) in
            make.centerX.equalTo(self)
            make.centerY.equalTo(self.snp.centerY).offset(-120.0)
//            make.height.width.equalTo(175);
        }
        houseIconView.snp.makeConstraints { (make) in
            make.center.equalTo(self.iconView.snp.center)
        }
        
        tipLabel.snp.makeConstraints { (make) in
            make.centerX.equalTo(self.houseIconView.snp.centerX)
            make.top.equalTo(self.houseIconView.snp.bottom).offset(margin)
            make.width.equalTo(236)
        }
        registerButton.snp.makeConstraints { (make) in
            make.left.equalTo(self.tipLabel.snp.left)
            make.top.equalTo(self.tipLabel.snp.bottom).offset(margin)
            make.width.equalTo(100)
        }
        loginButton.snp.makeConstraints { (make) in
            make.right.equalTo(self.tipLabel.snp.right)
            make.top.equalTo(self.tipLabel.snp.bottom).offset(margin)
            make.width.equalTo(self.registerButton.snp.width)
        }
        
        maskIconView.snp.makeConstraints { (make) in
            make.left.right.top.equalTo(self)
            make.bottom.equalTo(self.registerButton).offset(margin)
        }
    }
}
